<?php
/**
 * 管理员角色数据模块
 * @author
 */

class RoleModel extends CommonModel
{
    public function _before_fetch_datagrid($page = 1, $rows = 10)
    {
        $order_by = isset($_REQUEST['sort']) ? trim($_REQUEST['sort']) . ' ' .  trim($_REQUEST['order']) : 'role_id desc';
        $this->total = $this->count();
        $this->order($order_by);
        $this->limit($rows)->page($page);
        $this->rows = $this->select();
    }

    /**
     * 查询角色
     * @param bool $tree
     */
    public function role_list($where = '', $type = 'combobox')
    {
        $role_list = D('Role')->where($where)->select();
        $result = array();
        switch($type){
            case 'combobox':
                $result[] = array('role_id' => 0, 'role_name' => '全部');
                $result = array_merge($result, $role_list);
                break;
        }
        return $result;
    }
}